package jiyun.com.yiyanmeng;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import java.util.ArrayList;

import adapter.VideoAdaper;
import base.BaseFragment;
import bean.VideoBean;
import presenter.ViewPresenter;
import view.VideoView;

/**
 * Created by 裘翔 on 2019/11/6.
 */

public class VideoFragment extends BaseFragment<VideoView, ViewPresenter> implements VideoView {
    private RecyclerView mVideoRec;
    private SmartRefreshLayout mVideoSmc;
    private ArrayList<VideoBean.KechengBean> list;
    private VideoAdaper adaper;


    @Override
    protected ViewPresenter bindPresenter() {
        return new ViewPresenter();
    }

    @Override
    protected void initData() {
        mPresenter.loadData();
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initView(View view) {

        mVideoRec = (RecyclerView) view.findViewById(R.id.video_rec);
        mVideoSmc = (SmartRefreshLayout) view.findViewById(R.id.video_smc);
        mVideoRec.setLayoutManager(new LinearLayoutManager(getContext()));
        list = new ArrayList<>();
        adaper = new VideoAdaper(getActivity(), list);
        mVideoRec.setAdapter(adaper);

    }

    @Override
    protected int bindLayout() {
        return R.layout.vedio_fragment;
    }

    @Override
    public void showToast(String msg) {

    }

    @Override
    public void onSuccess(VideoBean videoBeans) {
           list.addAll(videoBeans.getKecheng());
           adaper.notifyDataSetChanged();
    }

    @Override
    public void onFailed(String str) {

    }
}
